<template>
  <el-config-provider :locale="locale">
    <router-view />
  </el-config-provider>
</template>

<script setup lang="ts">
import { onMounted, ref } from 'vue';
import { ElConfigProvider } from 'element-plus';

import { useRouter } from 'vue-router';

// 导入 Element Plus 语言包
import zhCn from 'element-plus/es/locale/lang/zh-cn';

const router = useRouter();

const locationUrl = ref();
const locale = ref(zhCn);

onMounted(() => {
  // 检测断网
  window.addEventListener('offline', () => {
    locationUrl.value = location.href;
    router.replace('/nonetwork');
  });
  window.addEventListener('online', () => {
    location.href = locationUrl.value;
  });
});
</script>
